import React from 'react'
import { setGlobal } from '../redux/actions/counter'
import { useDispatch } from 'react-redux'
import { View } from '@tarojs/components'
import Navbar from '../components/navbar/navbar'


const getGlobal = () => {
  const dispatch = useDispatch()
  let menuButtonObject = wx.getMenuButtonBoundingClientRect();
  wx.getSystemInfo({
    success: res => {
      let statusBarHeight = res.statusBarHeight,
        navTop = menuButtonObject.top,//胶囊按钮与顶部的距离
        navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top - statusBarHeight) * 2;//导航高度
      console.log(navHeight, navTop, menuButtonObject.height)

      console.log(setGlobal, 'setGlobal');
      dispatch(setGlobal({
        navHeight,
        navTop,
        menuButtonHeight: menuButtonObject.height
      }))
    },
    fail(err) {
      console.log(err);
    }
  })
}

const WithRedux = () => {
  getGlobal()
  return <>
  </>
}

export default NewNavbar = (...arg) => {
  return <WithRedux>
    <Navbar {...arg} />
  </WithRedux>
}


// export default WithRedux